﻿using System;
using System.Linq.Expressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using MyBasicLib.Data.ORMLiteNew; 
using MyBasicLib.Data.ORMLiteNew.SqlClient;
using RUC.Core.Entities;
using MyBasicLib.Data.ORMLiteV2;

namespace MyBasicLib.Test.Data.ORMLiteNew
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void ArchitectureTest1()
        { 
        }

        App app ;

        [TestMethod]
        public void TestMethodBracket1()
        {
           
            ////var Dc = new DataContext();
            //var q = from a in Dc.GetTable<App>()
            //        select a.Id;
            //q.ToList();
            //AssertHelper("SELECT [t0].[Id] AS [Id] FROM [App] [t0] WHERE [t0].[Id] = @p0 OR [t0].[Id] = @p1");

            //ExpressionParser sp = new SelectParser();
            //var sb=new System.Text.StringBuilder();
            //Expression<Func<App, App>> exp = p => new App() { Name=p.Id+p.Name };
            //sp.Translate(exp, sb, 0, new TableAliasCache(), new AttributeMappingProvider());
           var tc= new TableNameAliasCache();
            var app=new App();
            Expression<Func<App, string >> exp = p =>  p.Name;
            var sds = MyBasicLib.Data.ORMLiteNew.SqlClient.DbQueryProvider.GetMemberName(exp, tc);
            Assert.AreEqual("[t0].[Name]", sds);
            sds = MyBasicLib.Data.ORMLiteNew.SqlClient.DbQueryProvider.GetMemberName(exp, tc,false);
            Assert.AreEqual("[Name]", sds);

            Expression<Func<UnitTest1, string>> exp1 = p => p.app.Name;
            sds = MyBasicLib.Data.ORMLiteNew.SqlClient.DbQueryProvider.GetMemberName(exp1,tc);
            Assert.AreEqual("[t1].[Name]", sds);
            sds = MyBasicLib.Data.ORMLiteNew.SqlClient.DbQueryProvider.GetMemberName(exp1,tc,false);
            Assert.AreEqual("[Name]", sds);

            Expression<Func<UnitTest1, App>> exp2 = p => p.app;




        }

    }
}
